<?php
// Подгрузка классов ядра
$core_classes = opendir((php_sapi_name()=="cli" ? $_SERVER['argv']['2'] : "")."core");
while($name = readdir($core_classes)){
    if($name != '..' && $name != '.' && $name != 'autoload.php' && $name != '.svn' && $name != '_notes'){
        include_once (php_sapi_name()=="cli" ? $_SERVER['argv']['2'] : "").'core/'.$name;
        $core_class = explode('.', $name);
        if(file_exists((php_sapi_name()=="cli" ? $_SERVER['argv']['2'] : "").'config/'.$core_class[0].'.xml')) $$core_class[0] = new $core_class[0]((array) simplexml_load_file((php_sapi_name()=="cli" ? $_SERVER['argv']['2'] : "").'config/'.$core_class[0].'.xml'));
    }
}

// Динамическая подгрузка модулей при запросе
function __autoload($class_name){
    $file = (php_sapi_name()=="cli" ? $_SERVER['argv']['2'] : "")."modules/".$class_name."/index.php";
    if(file_exists($file)) include_once $file;
    else return false;
}
?>